﻿using System;

namespace XUCore.NetCore.DynamicWebApi
{
    [Serializable]
    [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class)]
    public class DynamicWebApiAttribute : Attribute
    {
        /// <summary>
        /// 是否映射当前接口
        /// </summary>
        public bool IsVisible { get; set; } = true;
        /// <summary>
        /// 当前API的路由前缀
        /// <para>{ApiPrefix}/area/apple/v1.0/list</para>
        /// </summary>
        public string ApiPrefix { get; set; }
        /// <summary>
        /// 域名字 AreaName
        /// <para>api/{Module}/apple/v1.0/list</para>
        /// </summary>
        public string Module { get; set; }
        /// <summary>
        /// 控制器名字 ControllerName
        /// <para>api/area/{Name}/v1.0/list</para>
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 版本号
        /// <para>api/area/apple/{Version}/list</para>
        /// </summary>
        public string Version { get; set; }

        // internal static bool IsExplicitlyEnabledFor(Type type)
        // {
        //     var remoteServiceAttr = type.GetTypeInfo().GetSingleAttributeOrNull<DynamicWebApiAttribute>();
        //     return remoteServiceAttr != null;
        // }

        // internal static bool IsExplicitlyDisabledFor(Type type)
        // {
        //     var remoteServiceAttr = type.GetTypeInfo().GetSingleAttributeOrNull<DynamicWebApiAttribute>();
        //     return remoteServiceAttr != null;
        // }

        // internal static bool IsMetadataExplicitlyEnabledFor(Type type)
        // {
        //     var remoteServiceAttr = type.GetTypeInfo().GetSingleAttributeOrNull<DynamicWebApiAttribute>();
        //     return remoteServiceAttr != null;
        // }

        // internal static bool IsMetadataExplicitlyDisabledFor(Type type)
        // {
        //     var remoteServiceAttr = type.GetTypeInfo().GetSingleAttributeOrNull<DynamicWebApiAttribute>();
        //     return remoteServiceAttr != null;
        // }

        // internal static bool IsMetadataExplicitlyDisabledFor(MethodInfo method)
        // {
        //     var remoteServiceAttr = method.GetSingleAttributeOrNull<DynamicWebApiAttribute>();
        //     return remoteServiceAttr != null;
        // }

        // internal static bool IsMetadataExplicitlyEnabledFor(MethodInfo method)
        // {
        //     var remoteServiceAttr = method.GetSingleAttributeOrNull<DynamicWebApiAttribute>();
        //     return remoteServiceAttr != null;
        // }
    }
}
